#include <iostream>
#include <iomanip>
#include <fstream>
#include <cstdlib>
#include <ctime>
#include <algorithm>
#include <numeric>
#include <vector>
#include <iterator>
#include <functional>
#include <boost/bind.hpp>
#include <boost/timer.hpp>
#include <boost/shared_ptr.hpp>

using namespace std;

void Test1()
{
	int *pi = new int(123);
	void *pv = pi;

	//int *pii = pv;//error
    int *pi2 = static_cast<int*>(pv);
	cout<<*pi2<<endl;

	double *pd = static_cast<double*>(pv); // not safe 
	//pd = static_cast<double*>(pi);// error: int*  ->  double*
	cout<<*pd<<endl;
}

// It is not a type safe way to use c++.
// void* to pointer to unknow type.
void print(int type, void* data)
{
	if(type==1)
		cout<<*static_cast<char*>(data)<<endl;
	if(type==2)
		cout<<*static_cast<int*>(data)<<endl;
	if(type==3)
		cout<<*static_cast<double*>(data)<<endl;
}

int main(int argc, char **argv)
{
	int    a = 1234;
	double b = 3e7;
	char   c = 'O';

	print(1, &c);
	print(2, &a);
	print(3, &b);

	return 0;
}
